package com.situ.service.impl;

import java.util.List;

import com.situ.dao.UserDao;
import com.situ.entity.User;
import com.situ.service.IUserService;

public class UserServiceImpl implements IUserService {

	UserDao userDao = new UserDao();

	@Override
	public void addUser(User user) {
		userDao.addUser(user);
	}

	@Override
	public User checkUser(String username, String password) {
		List<User> list = userDao.check(username, password);
		if (list == null || list.size() == 0) {
			return null;
		}
		return list.get(0);
	}

	@Override
	public Integer countUsers(String username, String name) {

		return userDao.count(username, name);
	}

	@Override
	public List<User> selectUsers(String username, String name, Integer pageSize, Integer pageNum) {
		return userDao.selectUsers(username, name, (pageNum - 1) * pageSize, pageSize);
	}

	@Override
	public void delUser(String id) {
		userDao.del(id);
	}

	@Override
	public User selectById(String id) {
		List<User> list = userDao.selectUserById(id);
		if (list == null || list.size() == 0) {
			return null;
		}
		return list.get(0);
	}

	@Override
	public void updateUser(User user) {
		userDao.update(user);

	}

}
